Skip to content

Fix WPS and CLI column alignment in scan display#451

Merged
kimocoder merged 1 commit into
masterfrom
claude/align-wps-clients-5HShb
Mar 6, 2026
Merged

Fix WPS and CLI column alignment in scan display#451
kimocoder merged 1 commit into
masterfrom
claude/align-wps-clients-5HShb

Conversation

@kimocoder

Copy link
Copy Markdown
Owner

The to_str() method used inconsistent column widths and separators that didn't match the header defined in scanner.py, causing WPS values to appear under the CLI header and client counts to overflow past the table.

  • Add _pad_colored() helper to pad ANSI-colored strings to exact visible widths
  • Use consistent 2-space separators between all columns
  • Match column widths (ESSID:26, BSSID:19, MFG:23, CH:4, ENCR:9, PWR:7, WPS:5, CLI:7)
  • Fix classic.py header to use same column order and widths as scanner.py

The to_str() method used inconsistent column widths and separators that
didn't match the header defined in scanner.py, causing WPS values to
appear under the CLI header and client counts to overflow past the table.

- Add _pad_colored() helper to pad ANSI-colored strings to exact visible widths
- Use consistent 2-space separators between all columns
- Match column widths (ESSID:26, BSSID:19, MFG:23, CH:4, ENCR:9, PWR:7, WPS:5, CLI:7)
- Fix classic.py header to use same column order and widths as scanner.py

https://claude.ai/code/session_019ijpUyTX2ZGrr1123Hteea
Copilot AI review requested due to automatic review settings March 6, 2026 01:22
@kimocoder kimocoder merged commit 6d31714 into master Mar 6, 2026
8 of 9 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR standardizes the classic scan table formatting so Target row strings (Target.to_str()) use consistent fixed-width columns and separators that match the header layout used by the scanner display, preventing WPS/CLI values from appearing under the wrong headers.

Changes:

  • Add a _pad_colored() helper in Target to pad ANSI-colored strings by visible width.
  • Rebuild Target.to_str() using fixed column widths and consistent 2-space separators.
  • Update the classic UI header to use the same column order and widths as the scanner view.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
wifite/ui/classic.py Rebuilds the classic “Targets” header to match the fixed-width scan table columns.
wifite/model/target.py Adds ANSI-aware padding and rewrites to_str() to emit consistently aligned, fixed-width columns.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread wifite/model/target.py
Comment on lines +361 to +383
# Column widths must match scanner.py header
COL_ESSID = 26
COL_BSSID = 19
COL_MFG = 23
COL_CH = 4
COL_ENC = 9
COL_PWR = 7
COL_WPS = 5
COL_CLI = 7
SEP = ' '

parts = [self._pad_colored(essid, COL_ESSID)]
if show_bssid:
parts.append(self._pad_colored(bssid, COL_BSSID))
if show_manufacturer:
parts.append(self._pad_colored(manufacturer, COL_MFG))
parts.append(self._pad_colored(channel, COL_CH, 'right'))
parts.append(self._pad_colored(encryption_display_string, COL_ENC))
parts.append(self._pad_colored(power, COL_PWR, 'right'))
parts.append(self._pad_colored(wps, COL_WPS, 'center'))
parts.append(self._pad_colored(clients, COL_CLI, 'right'))

result = SEP.join(parts)

Copilot AI Mar 6, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new fixed-width column formatting in Target.to_str() is meant to prevent header/data drift, but there are no tests asserting the exact column widths/separators (after stripping ANSI) for common combinations (with/without BSSID/MFG, different WPS states, different client counts). Adding a regression test that strips ANSI and checks column start positions/widths would help prevent this alignment bug from returning.

Copilot uses AI. Check for mistakes.
Comment thread wifite/model/target.py
Comment on lines +361 to +370
# Column widths must match scanner.py header
COL_ESSID = 26
COL_BSSID = 19
COL_MFG = 23
COL_CH = 4
COL_ENC = 9
COL_PWR = 7
COL_WPS = 5
COL_CLI = 7
SEP = ' '

Copilot AI Mar 6, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Column width constants are now duplicated across wifite/util/scanner.py, wifite/ui/classic.py, and Target.to_str(). This creates an ongoing risk of the alignment bug recurring if one location changes without updating the others. Consider centralizing these widths/separator into a shared constant (or a small helper) that both header builders and to_str() reference.

Copilot uses AI. Check for mistakes.
Comment thread wifite/ui/classic.py
for idx, target in enumerate(targets, start=1):
target_str = target.to_str(show_bssid=show_bssid, show_manufacturer=show_manufacturer)
Color.pl(' {G}%3d{W} %s' % (idx, target_str))
Color.pl(' {G}%s{W} %s' % (str(idx).rjust(col_num), target_str))

Copilot AI Mar 6, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In display_targets(), the table header starts with two leading spaces (header = ' ' + ...), but each row starts with a single leading space (Color.pl(' {G}%s{W} %s' ...)). This shifts the NUM column one character left relative to the header and can reintroduce alignment issues. Make the left padding consistent between header/separator and rows (either add one leading space to the row format string or drop one from the header/separator).

Suggested change
Color.pl(' {G}%s{W} %s' % (str(idx).rjust(col_num), target_str))
Color.pl(' {G}%s{W} %s' % (str(idx).rjust(col_num), target_str))

Copilot uses AI. Check for mistakes.
@kimocoder kimocoder deleted the claude/align-wps-clients-5HShb branch March 6, 2026 02:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants